package com.jiutianniao.p2p.acctrans.core.dal.dao;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import com.jiutianniao.p2p.acctrans.core.dal.model.AccountLogDO;
import com.jiutianniao.p2p.base.dao.BaseMapper;
import com.jiutianniao.p2p.trans.client.model.AccountLogQueryDto;
import com.jiutianniao.p2p.trans.client.model.AccountLogVO;

public interface AccountLogDao extends BaseMapper {

	@Insert("insert into account_log("
			+ "account_log_id,trans_log_id,trans_date,out_date,trans_dt,trans_code,trans_amount,balance,trans_currency,account_type,trans_account,other_account_type,other_account,trans_institution,trans_out_order_no,trans_memo,sub_trans_code,out_biz_no,is_write_off,is_red,delete_flag,voucher_id,trans_operator"
			+ ") values(#{accountLogId},#{transLogId},#{transDate},#{outDate},#{transDt},#{transCode},#{transAmount.cent},#{balance.cent},#{transCurrency},#{accountType},#{transAccount},#{otherAccountType},#{otherAccount},#{transInstitution},#{transOutOrderNo},#{transMemo},#{subTransCode},#{outBizNo},#{isWriteOff},#{isRed},#{deleteFlag},#{voucherId},#{transOperator})")
	void saveLog(AccountLogDO accountLogDO);

	//TODO ResultMap
	@Select("select trans_amount,balance,trans_code,trans_memo from account_log where TRANS_ACCOUNT=#{accountNo}")
	@Results(value = {
			@Result(property = "transAmount.cent", column = "trans_amount"),
			@Result(property = "balance.cent", column = "balance"),
			@Result(property = "transCode", column = "trans_code"),
			@Result(property = "transMemo", column = "trans_memo") })
	List<AccountLogVO> findLogList(String accountNo);

	List<AccountLogVO> queryByCondition(AccountLogQueryDto accountLogQueryDto);

}
